import {Component, Vue} from 'vue-property-decorator'

import { isMobile, isEmail, isUsername, isEmpty, successMessage, errorMessage } from '@/utils'

@Component
export default class Function extends Vue {
  /**
   * 是否空
   *
   * @param {any} str 待验证变量
   * @return {boolean}
   */
  public isEmpty(str: any) {
    return isEmpty(str)
  }
  /**
   * 验证用户名
   *
   * @param {string} value 待验证内容
   * @return {boolean}
   */
  public isUsername(value: string) {
    return isUsername(value)
  }
  
  /**
   * 验证密码
   *
   * @param {string} value 待验证内容
   * @return {boolean}
   */
  public isPassword(value: string) {
    return value.length >= 6 && value.length <= 16
  }
  
  /**
   * 验证手机号码
   *
   * @param {string} value 待验证内容
   * @return {boolean}
   */
  public isMobile(value: string) {
    return isMobile(value)
  }
  
  /**
   * 验证邮箱
   *
   * @param {string} value 待验证内容
   * @return {boolean}
   */
  public isEmail(value: string) {
    return isEmail(value)
  }

  /**
   * 复制成功
   *
   * @param {Object} event
   * @return {void}
   */
  public copySuccess(event: any): void {
    successMessage('复制成功！')
  }

  /**
   * 复制错误
   *
   * @param {Object} event
   * @return {void}
   */
  public copyError(event: any): void {
    errorMessage('复制错误！')
  }
}
